﻿@page "/read/{id:guid}"
@inherits PageComponentBase

<MAppBar App="true"
         Elevation="0">
    <MButton Icon="true"
             OnClick="NavigateToBack">
        <MIcon>
            mdi-arrow-left
        </MIcon>
    </MButton>

    <MSpacer></MSpacer>
    <MButton Icon="true"
             OnClick="()=>ShowShare=true">
        <MIcon>
            mdi-share-variant-outline
        </MIcon>
    </MButton>
    <MButton Icon="true"
             OnClick="OpenDeleteDialog">
        <MIcon>
            mdi-delete-outline
        </MIcon>
    </MButton>
    <MButton Icon="true"
             OnClick="OnEdit">
        <MIcon>
            mdi-pencil
        </MIcon>
    </MButton>

    <MultiMenu @bind-Value="ShowMenu"
               ListItemModels="ListItemModels">
        <ButtonContent>
            <MultiDisplay>
                <DesktopContent>
                    <MIcon>mdi-dots-horizontal</MIcon>
                </DesktopContent>
                <MobileContent>
                    <MIcon>mdi-dots-vertical</MIcon>
                </MobileContent>
            </MultiDisplay>
        </ButtonContent>
    </MultiMenu>
</MAppBar>

<ScrollContainer>
    <div id="screenshot" class="theme-element">
        <div class="px-3 d-flex align-end">
            <span class="text-h6 font-weight-bold">
                @(Diary.CreateTime.ToString("yyyy/MM/dd"))
            </span>
            <span class="pl-5 text-subtitle-1">
                @(I18n.ToWeek(Diary.CreateTime))
            </span>
            <MSpacer></MSpacer>
            <span class="text-subtitle-1">
                @(CounterValue())
            </span>
        </div>
        <div class="px-2">
            @if (ShowWeather)
            {
                <MChip Class="my-2 mr-2"
                       Outlined="true">
                    <MIcon Left="true">
                        @(GetWeatherIcon(Diary.Weather))
                    </MIcon>
                    @(I18n.T("Weather." + Diary.Weather))
                </MChip>
            }

            @if (ShowMood)
            {
                <MChip Class="my-2 mr-2"
                       Outlined="true">
                    <MIcon Left="true">
                        @(GetMoodIcon(Diary.Mood))
                    </MIcon>
                    @(I18n.T("Mood." + Diary.Mood))
                </MChip>
            }

            @if (ShowLocation)
            {
                <MChip Class="my-2 mr-2"
                       Outlined="true">
                    <MIcon Left="true">
                        mdi-map-marker-outline
                    </MIcon>
                    @(Diary.Location)
                </MChip>
            }
        </div>

        @if (ShowTitle)
        {
            <MTextField Value="@(Diary.Title)"
                        Class="pb-0 my-sm-4 user-select font-weight-bold"
                        Solo="true"
                        Flat="true"
                        TValue="string"
                        HideDetails="@("auto")"
                        Dense="true"
                        Readonly="true"
                        maxlength="20">
            </MTextField>
        }
        @if (Markdown)
        {
            <MarkdownPreview Value="@(Diary.Content)"
                             Class="my-sm-4 px-3 user-select"
                             Style="padding-top:10px">
            </MarkdownPreview>
        }
        else
        {
            <MTextarea Value="@(Diary.Content)"
                       Class="my-sm-4 user-select"
                       Solo="true"
                       Flat="true"
                       HideDetails="@("auto")"
                       Readonly="true"
                       AutoGrow="true"
                       Rows="8"
                       RowHeight="30">
            </MTextarea>
        }

        <div class="mb-5">
            <MChipGroup Column="true">
                @foreach (var item in Tags)
                {
                    <MChip Outlined="true">
                        @(item.Name)
                    </MChip>
                }
            </MChipGroup>
        </div>
    </div>
</ScrollContainer>

<ShareDialog @bind-Value="ShowShare"
             Items="ShareItems">
</ShareDialog>

<DeleteDialog @bind-Value="ShowDelete"
              Title="@(I18n.T("Diary.Delete.Title"))"
              Content="@(I18n.T("Diary.Delete.Content"))"
              OnOK="HandleDelete">
</DeleteDialog>

<ExportDialog @bind-Value="ShowExport"
              Diaries="ExportDiaries">
</ExportDialog>